/*
 * Copyright 2024 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package androidx.compose.ui.awt

import androidx.compose.ui.ExperimentalComposeUiApi
import androidx.compose.ui.ComposeFeatureFlags
import org.jetbrains.skiko.SkikoProperties

/**
 * Configuration class for rendering settings.
 *
 * @property isVsyncEnabled Indicates whether presentation vsync is enabled or not
 * When true, the internal implementation will attempt to synchronize drawable presentations
 * with vsync. It guarantees that the frame is presented without visual artifacts like tearing in
 * exchange for a latency increase.
 * When false, the internal implementation will not attempt to synchronize drawable presentations
 * it can reduce latency but may introduce visual artifacts like screen tearing.
 * When null, the internal implementation will use the global configuration from [SkikoProperties.vsyncEnabled]
 *
 * This flag has no effect if [ComposeFeatureFlags.useSwingGraphics] is true. In this case Compose
 * will render the content to Swing provided offscreen buffer and the presentation will be controlled
 * by Swing.
 */
@ExperimentalComposeUiApi
class RenderSettings(
    val isVsyncEnabled: Boolean?
) {
    companion object {
        /**
         * Default rendering settings
         */
        val Default = RenderSettings(
            isVsyncEnabled = null
        )
    }
}